@svizzle/utils/array-[string-string]

Methods

(static) sliceStringAt(range) → {function}

Source:
Since:
  • 0.5.0
See:

Return a function extracting the portion of a string between the provided indices (first included, second excluded). Note that indices can be negative.

Example
> slicerPosPos = sliceStringAt([3, 5])
> slicerPosPos('0123456789')
'34'

> slicerPosImplicit = sliceStringAt([3])
> slicerPosImplicit('0123456789')
'3456789'

> slicerPosNeg = sliceStringAt([1, -3])
> slicerPosNeg('0123456789')
'123456'

> slicerNegPos = sliceStringAt([-6, 6])
> slicerNeg3('0123456789')
'45'
Parameters:
Name Type Description
range Array.<number>

[beginIndex, endIndex]

Properties
Name Type Attributes Description
0 number

The zero-based index at which to begin extraction

1 number <optional>

Optional. The zero-based index before which to end extraction. If negative, starts counting from the end.

Returns:
  • Function - String -> Boolean
Type
function